import MyTable from '@/components/MyTable';
import { findByAgentBySelectList } from '@/services/agent';
import { getResult } from '@/services/sys/attribute';
import { findByPageList } from '@/services/users';
import { Tag } from 'antd';
import React from 'react';
const columns = [
  {
    title: '编号',
    dataIndex: 'id',
    key: 'id',
  },
  {
    title: '头像',
    dataIndex: 'avatar',
    key: 'avatar',
    valueType: 'avatar',
    search: false,
  },
  {
    title: '名称',
    dataIndex: 'nickname',
    key: 'nickname',
    width: 'md',
    search: false,
  },
  {
    title: '认证名称',
    dataIndex: 'authName',
    key: 'authName',
    width: 'md',
  },
  {
    title: '代理及',
    dataIndex: 'agentId',
    key: 'agentId',
    width: 'md',
    valueType: 'select',
    request: findByAgentBySelectList,
  },
  {
    title: '手机号',
    dataIndex: 'phone',
    key: 'phone',
    width: 'md',
  },
  {
    title: '注册时间',
    dataIndex: 'createDate',
    key: 'createDate',
    width: 'md',
    valueType: 'date',
    search: false,
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
    width: 'md',
    valueType: 'select',
    valueEnum: await getResult('userstatus'),
    render: (_, record) => <Tag color={record.status.color}>{_}</Tag>,
  },
  {
    title: '操作',
    width: '164px',
    key: 'option',
    valueType: 'option',
    render: (_: any, row: API.Agent, index: number, action: any) => [
      // eslint-disable-next-line react/jsx-key
      <a href={`/users/show/${row.id}`}>查询</a>,
    ],
  },
];
export const Index: React.FC = () => {
  //userstatus
  return <MyTable search={true} request={findByPageList} columns={columns} />;
};
export default Index;
